import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Random;

/*
 * Measure the network speed in terms of bytes/second; your parameter space
should include the loopback interface card (between 2 processes on the same node),
the TCP protocol stack, UDP, varying packet/buffer size (1B, 1KB, 64KB), and varying the
concurrency (1 thread & 2 threads). The metrics you should be measuring are
throughput (Megabits per second, Mb/sec) and latency (ms)  1*2*3*2 = 12
experiments.

 */

public class Environment {
	public static final int B = 1;
	public static final int KB = 1024; 
	public static final int KB64 = 64*KB;
	public static final int MB = 1048576;
	
	private String _loopbackAddr;
	private int _protocol; // TCP=0 or UDP=1
	private int _bufferSize; 
	private int _nbThread;
	private int _port;
	
	public Environment(){
		_loopbackAddr = "localhost";		
		_protocol = 0; 
		_bufferSize = B; 
		_nbThread = 1;
		 BufferedReader in;
		try {
			in = new BufferedReader(new FileReader("../../.BMport"));
			_port = Integer.parseInt(in.readLine());
			 in.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (NumberFormatException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public String get_loopbackAddr() {
		return _loopbackAddr;
	}

	public void set_loopbackAddr(String _loopbackAddr) {
		this._loopbackAddr = _loopbackAddr;
	}

	public int get_protocol() {
		return _protocol;
	}

	public void set_protocol(int _protocol) {
		this._protocol = _protocol;
	}

	public int get_bufferSize() {
		return _bufferSize;
	}

	public void set_bufferSize(int _bufferSize) {
		this._bufferSize = _bufferSize;
	}

	public int get_nbThread() {
		return _nbThread;
	}

	public void set_nbThread(int _nbThread) {
		this._nbThread = _nbThread;
	}
	

	public int get_port() {
		return _port;
	}
	
	public void toPrint(){
		System.out.println("Protocole " + _protocol);
		System.out.println("Size " + _bufferSize);
		System.out.println("address " + _loopbackAddr);
		System.out.println("Port " + _port);
		System.out.println("nbThread " + _nbThread);
	}
	
}
